package com.foxzzz.datamemory.repository;

import com.foxzzz.datamemory.entity.BookNote;
import com.foxzzz.datamemory.entity.ReadRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;


public interface BookNoteRepository extends JpaRepository<BookNote,String> {
    @Query(value = "SELECT v FROM BookNote v WHERE  v.nextReviewDate<:moment and v.state='START'",
            countQuery = "SELECT count(v) FROM ReadRecord v  WHERE  v.lastNeedReview<:moment and v.state='START'"
    )
    Page<BookNote> findAllNeedVisit(Date moment, Pageable pageable);
}
